package com.jackie.coupon.template.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * com.jackie.coupon.template.api.enums.CouponType
 *
 * @author Jackie Hou
 * @date 2023/11/13 15:27
 * @version 1.0
 */
@Getter
@AllArgsConstructor
public enum CouponType {

    UNKONW("unknown", "0"),
    MONEY_OFF("满减券", "1"),
    DISCOUNT("打折", "2"),
    RANDOM_DISCOUNT("随机数", "3"),
    LONELY_NIGHT_MONEY_OFF("晚间双倍优惠券", "4"),
    ANTI_PUA("PUA加倍奉还券", "5");

    private String description;

    private String code;

    public static CouponType convert(String code) {
        return Stream.of(values())
                .filter(e -> e.code.equalsIgnoreCase(code))
                .findFirst()
                .orElse(UNKONW);
    }
}
